﻿define([], function(){
    var tpl = {};
    tpl.tabs = function(){
        var html = '';
        html += tabs();
        return html;
    };
    tpl.init1 = function(){
        var html = '';
        html += basicInfo();
        return html;
    };
    tpl.init2 = function(){
        var html = '';
        html += nbna();
        return html;
    };
    tpl.init3 = function(){
        var html = '';
        html += quesTabs();
        return html;
    };
    tpl.init4 = function(){
        var html = '';
        html += resultInfo();
        return html;
    };
    tpl.init5 = function(){
        var html = '';
        html += result();
        return html;
    };
    tpl.init6 = function(){
        var html = '';
        html += history();
        return html;
    };
    tpl.init7 = function(){
        var html = '';
        html += guides();
        return html;
    };
    var tabs = function(){
        return '<script type = "text/html" id="tabs-tpl">'+
            '{{each data as value,i}}'+
            '<li class="{{if i == 0}} checked {{/if}}" quesType = "{{value.quesType}}" item = "{{value.item}}" ids = "{{value.ids}}" {{if value.end}}end = "{{value.end}}"{{/if}}>{{value.item}}</li>'+
            '{{/each}}'+
            '</script>'
    };
    var basicInfo = function(){
        return '<script type = "text/html" id="basic-tpl">'+
                    '<li>姓名：{{userName}}</li>'+
                    '<li>{{if flag == 1}}实际月龄{{else if flag == 2}}纠正月龄{{/if}}：{{monthAge}}</li>'+
                    '<li>测试日期：{{testDate}}</li>'+
                '</script>'
    };
    var nbna = function(){
        return '<script type = "text/html" id="nbna-tpl">'+
                    '{{each data as value,i}}'+
                    '<ul class="clearfix ques-item {{if i == 0}}ques-checked{{/if}}" id="{{value.id}}" options="{{value.option}}" score = "{{value.score}}">'+
                        '<li><div>{{value.id}}</div></li>'+
                        '<li><div>{{value.title}}</div></li>'+
                        '<li>{{value.desc}}</li>'+
                    '</ul>'+
                    '{{/each}}'+
                '</script>'
    };
    var quesTabs = function(){
        return '<script type = "text/html" id="quesTabs-tpl">'+
            '<li>评定</li>'+
            '{{each data as value,i}}'+
            '<li class="options" quesId="{{value.id}}" val= "{{value.value}}">{{value.opt}}</li>'+
            '{{/each}}'+
            '</script>'
    };
    var resultInfo = function(){
        return '<script type = "text/html" id="resultInfo-tpl">'+
                    '<div>基本<br/>信息</div>'+
                    '<div class="clearfix">'+
                        '<span>孩子姓名：{{userName}}</span>'+
                        '<span>性别：{{if gender == "N"}}男{{else}}女{{/if}}</span>'+
                        '<span>年龄：{{testAge}}</span>'+
                        '<span>评估医生：{{doctorName}}</span>'+
                    '</div>'+
            '</script>'
    };
    var result = function(){
        return '<script type = "text/html" id="result-tpl">'+
                    '<ul class="clearfix">'+
                        '<li style="width:{{behaviorAbilityWidth}}">行为能力 <br/> {{behaviorAbility}}分</li>'+
                        '<li style="width:{{passiveMuscleWidth}}">被动肌张力 <br/> {{passiveMuscle}}分</li>'+
                        '<li style="width:{{activeMusclesWidth}}">主动肌张力 <br/> {{activeMuscles}}分</li>'+
                        '<li style="width:{{originalReflectionWidth}}">原始反射 <br/> {{originalReflection}}分</li>'+
                        '<li style="width:{{generalResponseWidth}}">一般反应 <br/> {{generalResponse}}分</li>'+
                    '</ul>'+
                    '<div class="total-score">'+
                        '<div class="clearfix">'+
                            '<span>总分</span>'+
                            '<span>{{totalScore}}</span>'+
                            '<span>{{level}}</span>'+
                        '</div>'+
                    '</div>'+
                '</script>'
    };
    var guides =  function(){
        return '<script type = "text/html" id="guides-tpl">'+
                '{{each data as value}}'+
                    '{{if value.title}}'+
                        ' <div>'+
                            '<p class="number-title"><span class="right"></span>{{value.title}}</p>'+
                            '<ul>'+
                            '{{each value.lists as list}}'+
                                '<li>{{list.item}}</li>'+
                            '{{/each}}'+
                            '</ul>'+
                        '</div>'+
                    '{{else}}'+
                        ' <div>'+
                            '{{each value.lists as list,i}}'+
                            '{{if i == 0}}'+
                                '<p class="number-title"><span class="right"></span>{{list.item}}</p>'+
                            '{{else}}'+
                                '<p>{{list.item}}</p>'+
                            '{{/if}}'+
                            '{{/each}}'+
                        '</div>'+
                    '{{/if}}'+
                '{{/each}}'+
                '</script>'
    };
    var history = function(){
        return '<script type = "text/html" id="history-tpl">'+
                    '{{each data as value}}'+
                    '<li answerId = "{{value.answerId}}"><span class="right"></span>{{value.testTime}}({{value.testAge}})</li>'+
                    '{{/each}}'+
                '</script>'
    };
    return tpl;
});